package com.qf.controller;

import com.qf.pojo.User;
import com.qf.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @author 千锋健哥
 */
@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 查询所有用户列表
     * @return
     */
    @RequestMapping("/list")
    public String findUserList(Model model) {
        List<User> list = userService.findAll();
        //将数据放入model模型中, 传入页面
        model.addAttribute("userList", list);
        return "userList";
    }
}
